﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GRIP.Cuda;
using System.Runtime.InteropServices;

namespace ConsoleTest
{
    class Program
    {
        static void Main(string[] args)
        {
            CudaManager.InitializeCuda();
            int[] indices = new int[307200];
            for (int i = 0; i < indices.Length; i++)
            {
                indices[i] = i;
            }

            //CudaManager.SetMapIndices(indices);
            
            byte[] rgb = new byte[640 * 480 * 4];
            byte[] rgb2 = new byte[640 * 480 * 4];
            for (int i = 0; i < rgb.Length; i++)
                rgb[i] = 55;

            //Marshal.Copy(rgb, 0, source.GetHostColorFrame(), rgb.Length);

            long basetime = DateTime.Now.Ticks;
            long start = DateTime.Now.Ticks;
            int count = 0;
            //source.UploadColorFrame();
            //source.AlignColorFrame();
            while (start - basetime < 300000000)
            {
                // MY CUDA CODE
                {
                    //source.UploadColorFrame();
                    //source.AlignColorFrame();
                }

                // CPU CODE
                /*{
                    for (int i = 0; i < 640 * 480; i++)
                    {
                        int newIndex = indices[i];
                        int index = i * 4;
                        rgb2[index] = rgb[newIndex];
                        rgb2[index+1] = rgb[newIndex+1];
                        rgb2[index+2] = rgb[newIndex+2];
                        rgb2[index+3] = rgb[newIndex+3];
                    }
                }*/

                count++;
                start = DateTime.Now.Ticks;
            }

            Console.WriteLine((double)count / 30.0);
            Console.ReadLine();
        }
    }
}
